﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GorgonLibrary.Internal;
using System.Diagnostics;
using GorgonLibrary.Graphics;

namespace EngineOfEvermore.Imaging
{
    public sealed class SlimRenderer : GorgonLibrary.Graphics.Renderable
    {
        const int VERTEX_BUFFER_SIZE = 128;

        static SlimRenderer _instance = new SlimRenderer();

        public static SlimRenderer Instance
        {
            get { return _instance; }
        }

        private SlimRenderer():
            base( "EngineOfEvermore.Imaging.SlimRenderer" )
        {
            InitializeVertices( VERTEX_BUFFER_SIZE );
        }

        public void DrawVertices( VertexTypeList.PositionDiffuse2DTexture1[] vertices,
            int startIndex, int count )
        {
            Debug.Assert( count < VERTEX_BUFFER_SIZE );

            BeginRendering( false );

            for ( int inIndex = 0, outIndex = startIndex; inIndex < count; ++inIndex, ++outIndex )
            {
                Vertices[outIndex] = vertices[inIndex];
            }

            WriteVertexData( 0, count );

            EndRendering( false );
        }

        public override float UniformScale
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override PrimitiveStyle PrimitiveStyle
        {
            get { return PrimitiveStyle.TriangleList; }
        }

        public override bool UseIndices
        {
            get { return true; }
        }


        #region Deprecated Members inherited from GorgonLibrary.Graphics.Renderable
        public override System.Drawing.Color Color
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override int Opacity
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        protected override void UpdateDimensions()
        {
            throw new NotImplementedException();
        }

        public override void Draw( bool flush )
        {
            throw new NotImplementedException();
        }

        public override GorgonLibrary.Graphics.Renderable Clone()
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
